package easy;

import util.PrintUtils;

public class Solution_1475 {

    public int[] finalPrices(int[] prices) {
        int[] array = new int[prices.length];
        for (int i = prices.length - 1; i >= 0; i--) {
            int pre = 0;
            for (int j = i + 1; j < prices.length; j++) {
                if (prices[j] <= prices[i]) {
                    pre = prices[j];
                    break;
                }
            }
            array[i] = prices[i] - pre;
        }
        return array;
    }

    public static void main(String[] args) {
        Solution_1475 model = new Solution_1475();
        PrintUtils.arrayInt(model.finalPrices(new int[]{8, 4, 6, 2, 3}));
        PrintUtils.arrayInt(model.finalPrices(new int[]{1, 2, 3, 4, 5}));
        PrintUtils.arrayInt(model.finalPrices(new int[]{10, 1, 1, 6}));
    }
}
